<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.util.container.Container</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.util.container.Container");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791">tango.util.container.Container</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Apr 2008: Initial release<br><br>
<b>Authors:</b><br>
Kris<br><br>
<b>Since:</b><br>0.99.7<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L27">Container</a></span>
<script>explorer.outline.addDecl('Container');</script>;</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Utility functions and constants</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>int <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L35">defaultInitialBuckets</a></span>
<script>explorer.outline.addDecl('defaultInitialBuckets');</script>; [static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">default initial number of buckets of a non-empty hashmap</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>float <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L45">defaultLoadFactor</a></span>
<script>explorer.outline.addDecl('defaultLoadFactor');</script>; [static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">default load factor for a non-empty hashmap. The hash 
                table is resized when the proportion of elements per 
                buckets exceeds this limit
        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L53">reap</a></span>
<script>explorer.outline.addDecl('reap');</script>(V)(V <span class="funcparam">v</span>); [static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">generic value reaper, which does nothing</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L61">reap</a></span>
<script>explorer.outline.addDecl('reap');</script>(K, V)(K <span class="funcparam">k</span>, V <span class="funcparam">v</span>); [static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">generic key/value reaper, which does nothing</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L70">hash</a></span>
<script>explorer.outline.addDecl('hash');</script>(K)(K <span class="funcparam">k</span>, uint <span class="funcparam">length</span>); [static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">generic hash function, using the default hashing. Thanks
                to 'mwarning' for the optimization suggestion</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L88">Collect</a></span>
<script>explorer.outline.addDecl('Collect');</script>(T);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">generic GC allocation manager
                
</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L96">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">allocate a T sized memory chunk
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T*[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L107">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>(uint <span class="funcparam">count</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">allocate an array of T sized memory chunks
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L118">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(T* <span class="funcparam">p</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when a specific T[] is discarded
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L130">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(T*[] <span class="funcparam">t</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when a specific T[] is discarded
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L147">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(bool <span class="funcparam">all</span> = true);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when clear/reset is called on the host. 
                        This is a shortcut to clear everything allocated.
        
                        Should return true if supported, or false otherwise. 
                        False return will cause a series of discrete collect
                        calls</font><br><br></dd></dl></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L175">Malloc</a></span>
<script>explorer.outline.addDecl('Malloc');</script>(T);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Malloc allocation manager.</font><br><br>
<font color="black">Note that, due to GC behaviour, you should not configure
                a custom allocator for containers holding anything managed
                by the GC. For example, you cannot use a MallocAllocator
                to manage a container of classes or strings where those 
                were allocated by the GC. Once something is owned by a GC
                then it's lifetime must be managed by GC-managed entities
                &#40;otherwise the GC may think there are no live references
                and prematurely collect container contents&#41;.
        
                You can explicity manage the collection of keys and values
                yourself by providing a reaper delegate. For example, if 
                you use a MallocAllocator to manage key/value pairs which
                are themselves allocated via malloc, then you should also
                provide a reaper delegate to collect those as required.      
                
</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L183">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">allocate an array of T sized memory chunks
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T*[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L194">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>(uint <span class="funcparam">count</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">allocate an array of T sized memory chunks
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L205">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(T*[] <span class="funcparam">t</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when a specific T[] is discarded
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L217">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(T* <span class="funcparam">p</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when a specific T[] is discarded
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L234">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(bool <span class="funcparam">all</span> = true);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when clear/reset is called on the host. 
                        This is a shortcut to clear everything allocated.
        
                        Should return true if supported, or false otherwise. 
                        False return will cause a series of discrete collect
                        calls
                        
</font><br><br></dd></dl></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L267">Chunk</a></span>
<script>explorer.outline.addDecl('Chunk');</script>(T);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Chunk allocator</font><br><br>
<font color="black">Can save approximately 30% memory for small elements &#40;tested 
                with integer elements and a chunk size of 1000&#41;, and is at 
                least twice as fast at adding elements when compared to the 
                default allocator &#40;approximately 50x faster with LinkedList&#41;
        
                Note that, due to GC behaviour, you should not configure
                a custom allocator for containers holding anything managed
                by the GC. For example, you cannot use a MallocAllocator
                to manage a container of classes or strings where those 
                were allocated by the GC. Once something is owned by a GC
                then it's lifetime must be managed by GC-managed entities
                &#40;otherwise the GC may think there are no live references
                and prematurely collect container contents&#41;.
        
                You can explicity manage the collection of keys and values
                yourself by providing a reaper delegate. For example, if 
                you use a MallocAllocator to manage key/value pairs which
                are themselves allocated via malloc, then you should also
                provide a reaper delegate to collect those as required.
        
</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L288">config</a></span>
<script>explorer.outline.addDecl('config');</script>(int <span class="funcparam">chunks</span>, int <span class="funcparam">presize</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">set the chunk size and preallocate lists
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L304">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">allocate an array of T sized memory chunks
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T*[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L325">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>(uint <span class="funcparam">count</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">allocate an array of T sized memory chunks
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L336">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(T*[] <span class="funcparam">t</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when a specific T[] is discarded
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L348">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(T* <span class="funcparam">p</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when a specific T is discarded
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L370">collect</a></span>
<script>explorer.outline.addDecl('collect');</script>(bool <span class="funcparam">all</span> = true);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Invoked when clear/reset is called on the host. 
                        This is a shortcut to clear everything allocated.
        
                        Should return true if supported, or false otherwise. 
                        False return will cause a series of discrete collect
                        calls
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L389">newlist</a></span>
<script>explorer.outline.addDecl('newlist');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">list manager
                        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/Container.d?rev=3791#L406">block</a></span>
<script>explorer.outline.addDecl('block');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">list allocator
                        
</font><br><br></dd></dl></dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2008 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sat Aug  2 16:08:33 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>